<template>
	<view class="serviceSet-wrap">
		<view class="serviceSet-list">
			<view class="serviceSet-item">
				<view class="serviceSet-item-txt">接诊开关</view>
				<switch :checked="doctorInfo.onLineStatus" color="#6E99C7" @change="switchChange" />
			</view>

			<view class="serviceSet-item">
				<view class="serviceSet-item-txt">图文问诊价格</view>
				<uni-easyinput :maxlength="8" type="digit" v-model="doctorInfo.amount" placeholder="请输入图文问诊价格" />
			</view>

			<view class="serviceSet-item">
				<view class="serviceSet-item-txt">视频问诊价格</view>
				<uni-easyinput :maxlength="8" type="digit" v-model="doctorInfo.videoAmount" placeholder="请输入视频问诊价格" />
			</view>
		</view>

		<u-bottom-button value="保存设置" @click="settingServe"></u-bottom-button>
	</view>
</template>

<script>
import uBottomButton from '@/components/u-bottom-button/u-bottom-button.vue';
import uniEasyinput from '@/components/uni/uni-easyinput/uni-easyinput.vue';
export default {
	components: {
		uBottomButton,
		uniEasyinput
	},
	data() {
		return {
			doctorInfo: null
		};
	},
	onLoad(option) {
		this.getDoctorInfo();
	},
	onShow() {},
	methods: {
		//获取医生/药师个人信息
		getDoctorInfo() {
			this.$api.getDoctorInfo({}).then(res => {
				if (res.code == 200) {
					this.doctorInfo = res.result;
				}
			});
		},

		switchChange(e) {
			this.doctorInfo.onLineStatus = e.detail.value ? 1 : 0;
		},

		//服务设置
		settingServe() {
			if (this.doctorInfo.videoAmount && this.doctorInfo.amount) {
				this.$api
					.settingServe({
						data: this.doctorInfo
					})
					.then(res => {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					});
			} else {
				uni.showToast({
					title: '请填写问诊价格',
					icon: 'none'
				});
			}
		}
	}
};
</script>

<style lang="less">
@import 'serviceSet.less';
</style>
